// pages/common/pages/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentTab: 0,
    list: [{
      "text": "商品列表",
      "iconPath": "/imgs/list.png",
      "selectedIconPath": "/imgs/list_selected.png",
  
    },
    {
      "text": "购物车",
      "iconPath": "/imgs/cart.png",
      "selectedIconPath": "/imgs/cart_selected.png",
    },
      {
        "text": "个人中心",
        "iconPath": "/imgs/user.png",
        "selectedIconPath": "/imgs/user_selected.png",
      }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  /**
   * 根据底部tab切换，更改标题
   */
  tabChange(e) {
    var index = e.detail.index;
    console.log('tab change', e);
    this.setData({ currentTab: e.detail.index });
    if(index === 0){
      this.changeTitle("商品列表")
    }else if(index === 1){
      this.changeTitle("购物车")
    }else if(index === 2){
      this.changeTitle("个人中心")
    }
  },
  changeTitle(title) {
    wx.setNavigationBarTitle({
      title: title,
    })
  }
})